using Core;

namespace g_gongjianta
{
    public class Bullet : Unit
    {
        private long skillSrl;
        public TblSkill.Conf SkillConf { get; private set; }
        public TblSkill.BulletEvt BulletConf { get; private set; }

        public BulletMainComponent Main { get; private set; }

        public void Awake(long skill_srl, TblSkill.Conf skillConf, TblSkill.BulletEvt bulletConf)
        {
            base.Awake();

            skillSrl = skill_srl;
            SkillConf = skillConf;
            BulletConf = bulletConf;

#if UNITY_EDITOR
            gameObject.name = $"Bullet_{InstanceId}";
#endif

            Messenger.Post(Entity, "bullet_create", this);

            var visualParam = new VisualParam
            {
                Path = Global.BULLET_PREFAB_PATH,
                Icon = BulletConf.Icon,
                SortingOrder = 1,
            };

            Add<VisualComponent, VisualParam>(visualParam);
            Add<BulletMoveComponent>();
            Add<BulletCollisionComponent>();

            Main = Add<BulletMainComponent>();
        }
    }
}